<?php
echo $javascript->codeBlock("
	$(document).ready(function(){
		copyDelivery($('#CustomerDeliveryAsBilling').attr('checked'));
		$('#CustomerDeliveryAsBilling').bind('change', function (event) {
			copyDelivery($(this).attr('checked'));
		});
	});
	
	function copyDelivery(checked){
		if(checked){
			$('#CustomerDeliveryName').attr('value',$('#CustomerName').attr('value'));
			$('#CustomerDeliverySurname').attr('value',$('#CustomerSurname').attr('value'));
			$('#CustomerDeliveryAddress1').attr('value',$('#CustomerAddress1').attr('value'));
			$('#CustomerDeliveryAddress2').attr('value',$('#CustomerAddress2').attr('value'));
			$('#CustomerDeliveryAddress3').attr('value',$('#CustomerAddress3').attr('value'));
			$('#CustomerDeliveryAddress4').attr('value',$('#CustomerAddress4').attr('value'));
			$('#CustomerDeliveryAddress5').attr('value',$('#CustomerAddress5').attr('value'));
		}else{
			$('#CustomerDeliveryName').attr('value','');
			$('#CustomerDeliverySurname').attr('value','');
			$('#CustomerDeliveryAddress1').attr('value','');
			$('#CustomerDeliveryAddress2').attr('value','');
			$('#CustomerDeliveryAddress3').attr('value','');
			$('#CustomerDeliveryAddress4').attr('value','');
			$('#CustomerDeliveryAddress5').attr('value','');
		}
		
	}
",$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));
?>

<?php 
// wymagane w layout
echo $this->Section->main();
?>
<div class="content">
	<div id="left-column">
		<?php echo $this->element('left_column')?>		
	</div>
	<div class="right-store-column">
		<div  class="storeProducts">	
			<table width="100%" style="padding-top:0px; margin: 0px;" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2" align="center"><h2><?php echo __('New Customer')?></h2></td>
			</tr>
			<tr>
				<td align="left" valign="top" style="padding-top:0px; margin: 0px;" width="50%">
					<?php echo $this->Form->create('Customer',array('url'=>array('plugin'=>false,'controller'=>'users','action'=>'register')));?>
					<table width="100%" style="padding-top:0px; margin: 0px;" cellpadding="0" cellspacing="0">
						<tr>
							<td align="left" valign="top" style="padding-top:0px; margin: 0px;">
								<fieldset>
								<legend><h3><?php __d("store","Please enter your Billing details below"); ?></h3></legend>
								<?php
									echo $this->Form->hidden('id');
									echo $this->Form->hidden('user_id');
									echo $this->Form->input('name',array('label'=>__d("store","First Name",true)));
									echo $this->Form->input('surname',array('label'=>__d("store","Surname",true)));
									echo $this->Form->input('address1',array('label'=>__d("store","Address",true)));
									echo $this->Form->input('address2',array('label'=>__d("store","Address",true)));
									echo $this->Form->input('address3',array('label'=>__d("store","City",true)));
									echo $this->Form->input('address4',array('label'=>__d("store","Zip Code",true)));
									echo $this->Form->input('address5',array('label'=>__d("store","Country",true),'options'=>$countrycod));
									echo $this->Form->input('email',array('label'=>__d("store","E-mail",true)));
								?>
								</fieldset>
							</td>
							<td align="left" valign="top" style="padding-top:0px; margin: 0px;">										
								<fieldset>
							 		<legend><h3><?php __('Please enter your Delivery details below'); ?></h3></legend>
							 		<div class="input text required">
										<label for="CustomerDeliveryAsBilling"><?php echo __d("store","Same as Billing Details?",true);?></label>
										<?php 
										echo $this->Form->checkbox('delivery_as_billing',array('hiddenField' => false)); 
										$this->Js->get('#CustomerDeliveryAsBilling');
										$this->Js->event( 'change', 'copyDelivery($("#CustomerDeliveryAsBilling").attr("checked"));' ,true);
										?>	
									</div>
								<?php									
									echo $this->Form->input('delivery_name',array('label'=>__d("store","First Name",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_surname',array('label'=>__d("store","Surname",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_address1',array('label'=>__d("store","Address",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_address2',array('label'=>__d("store","Address",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_address3',array('label'=>__d("store","City",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_address4',array('label'=>__d("store","Zip Code",true),'class'=>'delivery_files'));
									echo $this->Form->input('delivery_address5',array('label'=>__d("store","Country",true),'class'=>'delivery_files','options'=>$countrycod));
								?>
								</fieldset>
							</td>
						</tr>
					</table>
					<input type="image" src="/img/store.moon/buttons_submit.png" style="border: none; padding: 0px; margin: 4px;" />
					<?php echo $this->Form->end();?>
				</td>
			</tr>

			</table>
		</div>
	</div>
</div>